'''
Created on 12 juin 2013

@author: Nils Amiet
'''

# Database routers are used to know which model should be used with which database.
# This is useful in our case because we have multiple databases.

class TwitterRouter():
    def db_for_read(self, model, **hints):
        if hasattr(model._meta, "isTwitterModel"):
            return "default"
        else:
            return "infrarouge"

    def db_for_write(self, model, **hints):
        if hasattr(model._meta, "isTwitterModel"):
            return "default"
        else:
            return "infrarouge"
    def allow_syncdb(self, db, model):
        isTwitterModel = hasattr(model._meta, "isTwitterModel")
        
        if isTwitterModel:
            return db == "default"
        else:
            return not db == "default"